package com.googlecode.kipler.satisfiability.completion.rule.individual.uniformnotation;

import com.googlecode.kipler.syntax.concept.BooleanConcept;
import com.googlecode.kipler.syntax.concept.Concept;
import com.googlecode.kipler.syntax.concept.BooleanConcept.Constructor;

public class UnionBetaConcept implements BetaConcept {

	private BooleanConcept union;

	private Concept beta1, beta2;

	private boolean valid;

	public UnionBetaConcept() {
		super();
	}

	public UnionBetaConcept(Concept concept) {
		setBeta(concept);
	}

	@Override
	public Concept getBeta() {
		return union;
	}

	@Override
	public void setBeta(Concept concept) {
		valid = false;
		if (concept instanceof BooleanConcept) {
			union = (BooleanConcept) concept;
			if (union.getConstructor() == Constructor.UNION) {
				beta1 = union.getLhs();
				beta2 = union.getRhs();
				valid = true;
			}
		}
	}

	@Override
	public Concept getBeta1() {
		return beta1;
	}

	@Override
	public Concept getBeta2() {
		return beta2;
	}

	public boolean isValid() {
		return valid;
	}

}
